﻿using ExchangeClient.Abstractions;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Logging;
using SyncService.Abstractions.Events;
using SyncService.Abstractions.Services;
using System;
using System.Collections.Generic;
using System.Composition;
using System.Linq;
using System.Text;
using System.Text.Json.Nodes;
using System.Threading.Tasks;

namespace SyncService.Core.Services
{
    [Export(typeof(ISyncService))]
    [ExportMetadata(YdConstants.ID, "Brand")]
    public class BrandServices : AssetSyncServiceBase
    {
        private IMemoryCache? _cache = null;
        private ILogger<BrandServices> _logger = null;

        public BrandServices() : base(YdConstants.YIDEA, "mysqlcache", "")
        {
        }

        protected override void InitializeContext()
        {
            base.SetMultiCallback();
            base.InitializeContext();
            _cache = Resolver.Resolve<IMemoryCache>();
            _logger = Resolver.Resolve<ILogger<BrandServices>>();
        }

        // Implementing the missing abstract method ExecuteCore from AssetSyncServiceBase  
        public override void ExecuteCore()
        {
            AssetSyncEvent Data = (AssetSyncEvent)State!;
            if (ToClient == null)
            {
                _logger?.Log(LogLevel.Error, "ToClient is null. Cannot proceed with ExecuteCore.");
                return;
            } 
            
            var ss= YideaClient.GetAssetTypes(null).ToList();
            
            _logger?.Log(LogLevel.Information, "ExecuteCore method executed.");

            JsonObject keyValuePairs = new JsonObject();
            keyValuePairs.Add("Flag","1");
            var sss=ToClient.GetData(keyValuePairs);
            //来试下
            var a = "";
        }
    }
}
